<extend name="Common/panel-block"/>
<block name="body">
    <form action="{:U()}" method="post" class="layui-form layui-clear" ajaxSubmit>
        <div class="layui-col-lg8">
            <div class="layui-tab">
                <ul class="layui-tab-title">
                    <li class="layui-this">基础</li>
                    <li>高级</li>
                </ul>
                <div class="layui-tab-content">
                    <!-- 基础 -->
                    <div class="layui-tab-item layui-show">
                        <icy8:formItem label="字段标识" help="创建后为字段名">
                            <input name="name" class="layui-input" placeholder="字段标识" value="{$info.name}"/>
                        </icy8:formItem>
                        <icy8:formItem label="字段标题" help="请输入字段标题，用于表单显示">
                            <input name="title" class="layui-input" placeholder="字段标题" value="{$info.title}"/>
                        </icy8:formItem>
                        <icy8:formItem label="字段类型" help="用于表单中的展示方式">
                            <Html:select id='" lay-filter="form"' name="form" options="field_type" selected="info['form']"/>
                        </icy8:formItem>
                        <icy8:formItem label="字段定义" help="字段属性的sql表示">
                            <input name="attribute" class="layui-input" placeholder="字段定义" value="{$info.attribute}"/>
                        </icy8:formItem>
                        <icy8:formItem label="参数" help="布尔、枚举、多选字段类型的定义数据">
                            <textarea name="form_param" class="layui-textarea">{$info.form_param}</textarea>
                        </icy8:formItem>
                        <icy8:formItem label="默认值" help="字段的默认值">
                            <input type="text" name="value" class="layui-input" placeholder="默认值"
                                   value="{$info.value}"/>
                        </icy8:formItem>
                        <icy8:formItem label="字段备注" help="用于表单中的提示">
                            <input type="text" name="remark" class="layui-input" placeholder="字段备注"
                                   value="{$info.remark}"/>
                        </icy8:formItem>
                        <icy8:formItem label="是否显示" help="是否显示在表单中">
                            <select name="is_show">
                                <option value="1">始终显示</option>
                                <option value="2">新增显示</option>
                                <option value="3">编辑显示</option>
                                <option value="0">不显示</option>
                            </select>
                        </icy8:formItem>
                        <icy8:formItem label="是否必填" help="用于自动验证">
                            <input type="radio" name="is_must" value="1" title="必填" checked/>
                            <input type="radio" name="is_must" value="0" title="选填"/>
                        </icy8:formItem>
                    </div>
                    <!-- 高级 -->
                    <div class="layui-tab-item">
                        <icy8:formItem label="验证方式">
                            <Html:select name="validate_type" options="validate_type" selected="info['validate_type']"/>
                        </icy8:formItem>
                        <icy8:formItem label="验证规则" help="根据验证方式定义相关验证规则">
                            <input type="text" class="layui-input" placeholder="验证规则" name="validate_rule" value="{$info.validate_rule}" />
                        </icy8:formItem>
                        <icy8:formItem label="出错提示">
                            <input type="text" class="layui-input" placeholder="出错提示" name="error_info" value="{$info.error_info}" />
                        </icy8:formItem>
                        <icy8:formItem label="验证时间">
                            <select name="validate_time">
                                <option value="3">始 终</option>
                                <option value="1">新 增</option>
                                <option value="2">编 辑</option>
                            </select>
                        </icy8:formItem>
                        <icy8:formItem label="自动完成方式">
                            <select name="auto_type">
                                <option value="function">函数</option>
                                <option value="field">字段</option>
                                <option value="string">字符串</option>
                            </select>
                        </icy8:formItem>
                        <icy8:formItem label="自动完成规则" help="根据完成方式订阅相关规则">
                            <input name="auto_rule" class="layui-input" placeholder="自动完成规则" value="{$info.auto_rule}" />
                        </icy8:formItem>
                        <icy8:formItem label="自动完成时间">
                            <select name="auto_time">
                                <option value="3">始 终</option>
                                <option value="1">新 增</option>
                                <option value="2">编 辑</option>
                            </select>
                        </icy8:formItem>
                    </div>
                </div>
            </div>
            <icy8:formItem label="">
                <input type="hidden" name="id" value="{$info.id}"/>
                <input type="hidden" name="model_id" value="{$model_id}"/>
                <icy8:button title="保存"/>
                <icy8:button title="返回" click="window.history.go(-1);" btnType="primary" type="button"/>
            </icy8:formItem>
        </div>
    </form>
</block>
<block name="script">
    <script type="text/javascript">
        Think.setValue('is_show', '{$info.is_show}');
        Think.setValue('is_must', '{$info.is_must}');
        Think.setValue('validate_type', "{$info.validate_type|default='regex'}");
        Think.setValue('validate_time', "{$info.validate_time|default=3}");
        Think.setValue('auto_type', "{$info.auto_type|default='function'}");
        Think.setValue('auto_time', "{$info.auto_time|default=3}");
    </script>
</block>
<block name="mod_script">
    var field_type = {$parse_field_type|json_encode};
    if(!$('input[name=attribute]').val()) {
        $('input[name=attribute]').val(field_type['num'][1]);
    }
    layui.form.on('select(form)',function (data) {
        var type_val = data.value||'num';
        $('input[name=attribute]').val(field_type[type_val][1]);
    });
</block>